package AutoTraderFraudCalculator;
import java.util.*;

/**
 * <code>Listing</code> is a class that adds the ability to access a car ad
 * listing through a medium. The listing class holds one particular car ad
 * listing with a title, URL and many specifications.
 * 
 */
public class Listing 
{
    private String title;
    private String url;
    private Map<String, String> specifications;
    
    /**
     * Constructs a <code>TreeMap<String, String></code> to hold the
     * specifications.
     */
    public Listing()
    {
        specifications = new TreeMap<String, String>();
    }
    
    /**
     * Set the title of the listing.
     * 
     * @param adTitle The title of the listing.
     */
    public void setTitle(String adTitle)
    {
        title = adTitle;
    }
    
    /**
     * Set the URL that the listing is using.
     * 
     * @param adUrl A <code>String</code> representation of a URL.
     */
    public void setUrl(String adUrl)
    {
        url = adUrl;
    }
    
    /**
     * Add/replace a specification.
     * 
     * @param adSpecType The name of the specification.
     * @param adSpecValue The specification value.
     */
    public void setSpecification(String adSpecType, String adSpecValue)
    {
        specifications.put(adSpecType, adSpecValue);
    }
    
    /**
     * Retrieve the title of this <code>Listing</code> instance.
     * 
     * @return The title of this instance.
     */
    public String getTitle()
    {
        return title;
    }
    
    /**
     * Retrieve the URL that this listing is referring to.
     * 
     * @return The URL of this instance.
     */
    public String getUrl()
    {
        return url;
    }
    
    /**
     * Retrieve the map that contains the specifications of this listing.
     * 
     * @return The <code>Map<String, String></code> with all the
     *         specifications that were put into this listing.
     * @see #setSpecification(java.lang.String, java.lang.String)
     */
    public Map<String, String> getSpecs()
    {
        return specifications;
    }
}